package cn.tedu.util;

import javax.xml.stream.events.StartDocument;
import java.util.ArrayList;
import java.util.LinkedList;

//测试  Arraylist和liskedlist
public class Test2_1 {
    public static void main(String[] args) {
        method();
        method2();
    }

    public static void method2() {
        ArrayList<Integer>  list=new ArrayList<>();
        for (int i = 0; i < 100000; i++) {
            list.add(i);
        }
        long atart=System.currentTimeMillis();
        for (int i = 0; i < list.size(); i++) {
            Integer date =list.get(i);

        }
        long end =System.currentTimeMillis();
        System.out.println(end- atart);
    }

    public static void method() {
        long start =System.currentTimeMillis();
        LinkedList<Integer> list=new LinkedList<>();
        for (int i = 0; i <100000 ; i++) {
            list.add(i);
        }
        for(int i=0;i<list.size();i++){
            Integer date =list.get(i);
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
}
